﻿Imports Microsoft.WindowsMobile.PocketOutlook


Public Class EventAdd

    Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
        HomeForm.Show()
        Me.Hide()
    End Sub

    Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
      
    End Sub

    Private Sub EventAdd_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load


        RefreshContacts()
    End Sub

    Private Sub EventView_Closing(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        HomeForm.Show()
    End Sub

    Private Sub AddContact_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddContact.Click
        For Each contactItem As ListViewItem In ContactsListBox.Items
            If contactItem.Selected Then
                Dim newContactItem As New ListViewItem(contactItem.Text)

                InviteesListBox.Items.Add(newContactItem)
            End If
        Next
        RefreshContacts()
    End Sub

    Private Sub RefreshContacts()
        ContactsListBox.Items.Clear()

        Dim poom As Microsoft.WindowsMobile.PocketOutlook.OutlookSession
        poom = New OutlookSession

        For Each contact As Contact In poom.Contacts.Items
            Dim contactItem As New ListViewItem
            contactItem.Text = contact.FirstName() & " " & contact.LastName()

            If Not (InviteesListBox.Items.Contains(contactItem)) Then
                ContactsListBox.Items.Add(contactItem)
            End If
        Next

    End Sub

    Private Sub RemoveContact_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RemoveContact.Click
        For Each contactItem As ListViewItem In InviteesListBox.Items
            If contactItem.Selected Then
                InviteesListBox.Items.Remove(contactItem)
            End If
        Next
    End Sub
End Class